package backend

import (
	"fmt"
	"os"
	"os/user"
	"path/filepath"
	"runtime"
)

func GetRoot() string {
	binary, _ := os.Executable()
	root := filepath.Dir(binary)
	return root
}

func GetUserData(env string) string {
	userDataPath := ""
	u, err := user.Current()
	if err != nil {
		fmt.Println(err)
		return ""
	}
	switch runtime.GOOS {
	case "windows":
		if env == "dev" {
			userDataPath = fmt.Sprintf("%v\\AppData\\Roaming\\%v-dev.exe", u.HomeDir, APP_NAME)
		} else {
			userDataPath = fmt.Sprintf("%v\\AppData\\Roaming\\%v.exe", u.HomeDir, APP_NAME)
		}

	case "darwin":
	case "linux":

	}

	return userDataPath
}
func GetExe(env string) string {
	exePath := ""
	root := GetRoot()
	switch runtime.GOOS {
	case "windows":
		if env == "dev" {
			exePath = fmt.Sprintf("%v\\%v-dev.exe", root, APP_NAME)
		} else {
			exePath = fmt.Sprintf("%v\\%v.exe", root, APP_NAME)
		}

	case "darwin":
	case "linux":

	}

	return exePath
}
